package com.allprs.hmcs.controller;

import com.allprs.common.core.domain.AjaxResult;
import com.allprs.hmcs.enums.DeviceTypeEnum;
import com.allprs.hmcs.enums.NaturalTypeEnum;
import com.allprs.hmcs.pojo.reqBo.*;
import com.allprs.hmcs.pojo.resBo.BaseMap;
import com.allprs.hmcs.pojo.resBo.NameSelectRes;
import com.allprs.hmcs.service.ICatchmentService;
import com.allprs.hmcs.service.IDrainageService;
import com.allprs.hmcs.service.INaturalWaterService;
import com.allprs.hmcs.service.ISheltersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wjf
 * @描述: 驾驶舱控制层
 * @date 2024年01月16日
 * @version: 1.0
 */

@RestController
@RequestMapping("/cockpit")
@Api(tags = "驾驶舱")
@Slf4j
public class CockpitController {


    @Resource
    private INaturalWaterService naturalWaterService;

    @Resource
    private IDrainageService drainageService;

    @Resource
    private ISheltersService sheltersService;

    @Resource
    private ICatchmentService catchmentService;

    @ApiOperation(value = "查询自然水体详细信息")
    @GetMapping("/getNaturalInfo")
    public AjaxResult getNaturalInfo(NaturalQueryBo queryBo){

        return naturalWaterService.getNaturalInfo(queryBo);
    }


    @ApiOperation(value = "查询排水设施详细信息")
    @GetMapping("/getDrainageInfo")
    public AjaxResult getDrainageInfo(DrainageQueryBo queryBo){

        return drainageService.getDrainageInfo(queryBo);
    }


    @ApiOperation(value = "根据类型和名称匹配所有的数据")
    @GetMapping("/getSelectByName")
    public AjaxResult getSelectByName(CockpitQueryBo queryBo){
        return drainageService.getSelectByName(queryBo);
    }

    @ApiOperation(value = "驾驶舱详情查询")
    @GetMapping("/getInfo")
    public AjaxResult getInfo(NameSelectRes queryBo){
        return drainageService.getInfo(queryBo);
    }

    @ApiOperation(value = "查询应急避难所信息")
    @GetMapping("/getSheltersInfo")
    public AjaxResult getSheltersInfo(SheltersQueryBo queryBo){
        return sheltersService.getSheltersInfo(queryBo);
    }

    @ApiOperation(value = "查询汇水区详情")
    @GetMapping("/getCatchmentInfo")
    public AjaxResult getCatchmentInfo(CatchmentQueryBo queryBo){

        return catchmentService.getCatchmentInfo(queryBo);
    }

    @ApiOperation(value = "驾驶舱查询类型下拉框")
    @GetMapping("/getNaturalType")
    public AjaxResult getNaturalType(){

        List<BaseMap> collect = Arrays.stream(NaturalTypeEnum.values()).map(NaturalTypeEnum::toBaseMap).collect(Collectors.toList());

        return AjaxResult.success(collect);
    }


}
